package controller.servlet.paymentForms;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Card;
import controller.dao.Dao_Card;

public class editPaymentForms extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int codigo = Integer.parseInt(request.getParameter("cod"));
		Dao_Card daoc = new Dao_Card();
		Card c = daoc.list(codigo);
		request.setAttribute("card", c);
		RequestDispatcher rd = request.getRequestDispatcher("/admin/register-payment-forms.jsp");
		rd.forward(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		int codigo = Integer.parseInt(request.getParameter("cod"));
		Dao_Card daoc = new Dao_Card();
		Card c  = daoc.list(codigo);
		String flag = request.getParameter("flag");
	    c.setFlag(flag);
	    Dao_Card daoCard = new Dao_Card();
	    daoCard.update(c);
	    response.sendRedirect("/ShoppingCart.Com_V6/admin/payment-forms.ja");
	}

}
